{% extends 'base.html' %}
{% load static %}

{% block top %}
    {% if page_name == 'site' %}
        <div class="header_con">
            <div class="header">
                <div class="welcome fl">欢迎来到天天生鲜!</div>
                <div class="fr">
                    {% if user %}
                        <div class="login_info fl login_btn">
                            欢迎您：<em>
                                {% if user.nikename %}
                                    <a href="{% url 'info' %}">{{ user.nikename }}</a>
                                {% else %}
                                    <a href="{% url 'info' %}">{{ user.uname }}</a>
                                {% endif %}
                            </em>
                            <span>|</span>
                            <a href="{% url 'logout' %}">注销</a>
                        </div>
                    {% else %}

                        <div class="login_btn fl">
                            <a href="{% url 'login' %}">登录</a>
                            <span>|</span>
                            <a href="{% url 'register' %}">注册</a>
                        </div>
                    {% endif %}

                    <div class="user_link fl">
                        <span>|</span>
                        <a href="{% url 'info' %}">用户中心</a>
                        <span>|</span>
                        <a href="{% url 'cart' %}">我的购物车</a>
                        <span>|</span>
                        <a href="{% url 'order' %}">我的订单</a>
                    </div>
                </div>
            </div>
        </div>

        <div class="search_bar clearfix">
            <a href="{% url 'index' %}" class="logo fl"><img src="{% static 'images/logo.png' %}"></a>
            <div class="sub_page_name fl">|&nbsp;&nbsp;&nbsp;&nbsp;用户中心</div>
            <div class="search_con fr">
                 <form method='get' action="/search/" target="_blank">
                    <input type="text" class="input_text fl" name="q" placeholder="搜索商品">
                    <input type="submit" class="input_btn fr" name="" value="搜索">
                </form>
            </div>
        </div>
    {% else %}
        <div class="header_con">
            <div class="header">
                <div class="welcome fl">欢迎来到天天生鲜!</div>
                <div class="fr">
                   {% if user %}
                        <div class="login_info fl login_btn">
                            欢迎您：<em>
                                {% if user.nikename %}
                                    <a href="{% url 'info' %}">{{ user.nikename }}</a>
                                {% else %}
                                    <a href="{% url 'info' %}">{{ user.uname }}</a>
                                {% endif %}
                            </em>
                            <span>|</span>
                            <a href="{% url 'logout' %}">注销</a>
                        </div>
                    {% else %}

                    <div class="login_btn fl">
                        <a href="{% url 'login' %}">登录</a>
                        <span>|</span>
                        <a href="{% url 'register' %}">注册</a>
                    </div>
                    {% endif %}

                    <div class="user_link fl">
                        <span>|</span>
                        <a href="{% url 'info' %}">用户中心</a>
                        <span>|</span>
                        <a href="{% url 'cart' %}">我的购物车</a>
                        <span>|</span>
                        <a href="{% url 'order' %}">我的订单</a>
                    </div>
                </div>
            </div>
        </div>


        <div class="search_bar clearfix">
            <a href="{% url 'index' %}" class="logo fl"><img src="{% static 'images/logo.png' %}"></a>
            <div class="search_con fl">
                <form method='get' action="/search/" target="_blank">
                    <input type="text" class="input_text fl" name="q" placeholder="搜索商品">
                    <input type="submit" class="input_btn fr" name="" value="搜索">
                </form>
            </div>
            <div class="guest_cart fr">
                <a href="{% url 'cart' %}" class="cart_name fl">我的购物车</a>
                <div class="goods_count fl" id="show_count">{{ cart_count|default:'0' }}</div>
            </div>
        </div>

    {% endif %}


{% endblock %}